package com.wxzz.elearing.user.api.server;

import com.wxzz.elearing.user.service.IEnterpriseService;
import com.wxzz.elearing.user.service.IWxUserService;
import com.wxzz.elearning.common.dto.FeignWxUserDto;
import com.wxzz.elearning.common.vo.ReturnVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/wx-user-api")
public class WxUserApi {

    @Autowired
    private IEnterpriseService enterpriseService;

    /**
     * 根据微信用户id换取对应公司信息
     *
     * @param wxUserId
     * @return
     */
    @RequestMapping(value = "selectEnterpriseByWxUserId", method = RequestMethod.POST)
    public ReturnVO<String> selectEnterpriseByWxUserId(@RequestParam("wxUserId") Long wxUserId) {
        return enterpriseService.selectEnterpriseByWxUserId(wxUserId);
    }

    /**
     * 根据微信用户id换取用户信息
     *
     * @param wxUserId
     * @return
     */
    @RequestMapping(value = "selectWxUserByWxUserId", method = RequestMethod.POST)
    public ReturnVO<String> selectWxUserByWxUserId(@RequestParam("wxUserId") Long wxUserId) {
        return enterpriseService.selectWxUserByWxUserId(wxUserId);
    }

    /**
     * 根据微信用户id查询用户详情
     *
     * @param wxUserId
     * @return
     */
    @RequestMapping(value = "selectFeignWxUserDtoByWxUserId", method = RequestMethod.POST)
    public FeignWxUserDto selectFeignWxUserDtoByWxUserId(@RequestParam("wxUserId") Long wxUserId) {
        return wxUserService.selectFeignWxUserDtoByWxUserId(wxUserId);
    }

    /**
     * 根据讲师id查询用户详情
     *
     * @param docentId
     * @return
     */
    @RequestMapping(value = "selectFeignWxUserDtoByDocentId", method = RequestMethod.POST)
    public FeignWxUserDto selectFeignWxUserDtoByDocentId(@RequestParam("docentId") Long docentId) {
        return wxUserService.selectFeignWxUserDtoByDocentId(docentId);
    }

    @Autowired
    private IWxUserService wxUserService;

    /**
     * 查询用户列表
     *
     * @param map
     * @return
     */
    @RequestMapping(value = "listWxUserByMap", method = RequestMethod.POST)
    public ReturnVO<List<Long>> listWxUserByMap(@RequestBody Map<String, String> map) {
        return wxUserService.listWxUserByMap(map);
    }

}
